<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="pragma" content="no-cache"/>
    <meta http-equiv="cache-control" content="no-cache"/>
    <meta http-equiv="Expires" content="0"/>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
    <title>Title</title>
    <script type="text/javascript">
        function  ajaxRequest(){
            //1.创建XMLHttpRequest
            var  xmlhttprequest=new  XMLHttpRequest();
            //2.调用open方法设置请求参数
            xmlhttprequest.open("Get","http://localhost:8080/untitled/ajaxServlet?action=ajaxServlet,true");
            //3.调用sent方法发送请求
            xmlhttprequest.send();
            //4.在send方法前绑定onreadystatechange事件，处理请求后的操作
            xmlhttprequest.onreadystatechange=function (){
                if(xmlhttprequest.readyState==4&&xmlhttprequest.status==200){
                    alert(xmlhttprequest.responseText);
                }
            }
        }
    </script>
</head>
<body>
    <button onclick="ajaxRequest()">ajax request</button>
    <div id="div01">

    </div>

</body>
</html>